package com.cn.yugan.Engine.Http;

import com.cn.yugan.Utils.LogUtils;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.safety.Whitelist;
import org.jsoup.select.Elements;

/**
 * Created by Rover on 2016/10/12 .
 * Email 357319517@qq.com
 */
public class HtmlHandler {

    public static String ArticleinfoHandler(String info) {
        String str = Jsoup.clean(info, Whitelist.basicWithImages());
        Document doc_Dis = Jsoup.parse(str);
        Elements ele_Img = doc_Dis.getElementsByTag("img");
        Elements ele_a = doc_Dis.getElementsByTag("a");
        if (ele_Img.size() != 0) {
            for (Element e_Img : ele_Img) {
                if (e_Img.attr("src").contains("sinaimg")) {

                } else {
                    e_Img.attr("style", "width:100%");
                }
            }
            for (Element e_a : ele_a) {
                e_a.tagName("p");
            }
        }
        return doc_Dis.toString();
    }
}
